package JDBC;

import java.sql.*;


public class Main {
    public static void main(String[] args) {
        try (Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/web_study", "root", "031124");
             Statement statement = connection.createStatement()) {
            ResultSet set = statement.executeQuery("select * from user");
            while (set.next()) {   //使用next开始读取查询结果的下一行
                System.out.print(set.getInt("id") + " ");   //直接获取本行指定字段下的数据
                System.out.print(set.getString("name") + " ");
                System.out.println(set.getInt("age"));
            }
        }catch(SQLException e){
            e.printStackTrace();

        }
    }
}

